﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SR_MessageDemo.Messages;

namespace SR_MessageDemo
{
    public partial class MainForm : Form, IRecipiet<User>
    {
        public MainForm()
        {
            InitializeComponent();
            WeakReferenceMessager.Default.Regisit<User>(this);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void toolBar1_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
        {
            ToolBarButton button = e.Button;
            Control.ControlCollection controls = this.toolStripContainer1.ContentPanel.Controls;
            controls.Clear();
            if (button.Text == "用户管理")
            {
                FormList formList = new FormList();
                formList.TopLevel = false;
                formList.FormBorderStyle = FormBorderStyle.None;
                controls.Add(formList);
                formList.Show();
                formList.BringToFront();
            }
            
        }

        private void toolBar1_Click(object sender, EventArgs e)
        {
            Console.WriteLine();
        }

        public void HideMenus(User user)
        {
            if (user.Name == "程序员Ken")
            {
                toolBarButton2.Visible = user.Role == "管理员";
                toolBarButton3.Visible = user.Role == "管理员";
            }
        }

        public void Recive(User user)
        {
            if (user.Name == "程序员Ken")
            {
                toolBarButton2.Visible = user.Role == "管理员";
                toolBarButton3.Visible = user.Role == "管理员";
            }
        }

       
    }
}
